package com.teradata.singleton.innerclass;

public class LazyStaticInnerClassSingleton {

    private LazyStaticInnerClassSingleton() {
        synchronized (LazyStaticInnerClassSingleton.class) {
            if (!ConstructorKeeper.has_initialited){
                ConstructorKeeper.has_initialited = true;
            } else {
                throw new RuntimeException("请不要入侵我!");
            }
        }
        System.out.println("懒汉初始化");
    }

    public static final LazyStaticInnerClassSingleton getInstance() {
        return InstanseHolder.INSTANCE;
    }

    private static class InstanseHolder {
        private static final LazyStaticInnerClassSingleton INSTANCE = new LazyStaticInnerClassSingleton();
    }

    private static class ConstructorKeeper {
        private static boolean has_initialited = false;
    }

}
